<template>
  <div>我是新闻页</div>
  <p>store中的count:{{ count }}</p>
  <p>store中的计算属性:{{ fourtimes }}</p>
  <p><button @click="addcount">count++</button></p>
</template>

<script>
import { computed } from "vue";
import { useStore } from "vuex";
export default {
  name: "",
  props: [""],
  data() {
    return {};
  },
  setup() {
    // 01 :获取store 对象
    const store = useStore();
    console.log(store);
    let count = computed(() => {
      return store.state.count;
    });

    let fourtimes = computed(() => {
      return store.getters.fourTimes;
    });
    const addcount = () => {
      store.commit("add", 1);
    };
    return {
      count,
      addcount,
      fourtimes,
    };
  },
};
</script>
<style scoped>
</style>